package com.atuguigu.boot3.features;

import com.atuguigu.boot3.features.bean.Cat;
import com.atuguigu.boot3.features.bean.Dog;
import com.atuguigu.boot3.features.bean.Pig;
import com.atuguigu.boot3.features.bean.Sheep;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
public class Boot306FeaturesApplication {

	public static void main(String[] args) {
//		SpringApplication.run(Boot306FeaturesApplication.class, args);

		/*第一种改写方式 拆开写*/
		/*SpringApplication springApplication =new SpringApplication(Boot306FeaturesApplication.class);
		springApplication.setBannerMode(Banner.Mode.OFF);  //以配置文件为准
		springApplication.run(args);*/

		//第二种写法构造器的写法 流式api写法
	/*	new SpringApplicationBuilder()
				.main(Boot306FeaturesApplication.class)
				.sources(Boot306FeaturesApplication.class)
				.bannerMode(Banner.Mode.OFF)
//				.environment(null)
//				.listeners(null)
				.run(args);*/
		/*设置模式*/

		ConfigurableApplicationContext contex = SpringApplication.run(Boot306FeaturesApplication.class, args);
		try {
			Cat cat = contex.getBean(Cat.class);
			System.out.println("cat = " + cat);
		} catch (BeansException e) {
//			throw new RuntimeException(e);
		}
		try {
			Dog dog = contex.getBean(Dog.class);
			System.out.println("dog = " + dog);
		} catch (BeansException e) {
//			throw new RuntimeException(e);
		}
		try {
			Pig pig = contex.getBean(Pig.class);
			System.out.println("pig = " + pig);
		} catch (BeansException e) {
//			throw new RuntimeException(e);
		}
		try {
			Sheep sheep = contex.getBean(Sheep.class);
			System.out.println("sheep = " + sheep);
		} catch (BeansException e) {
//			throw new RuntimeException(e);
		}
	}


}
